// 1685329083274
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define inf 1e9
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define cy cout << "YES\n";
#define cn cout << "NO\n";
#define minus cout << "-1\n";
#define fo(a, b) for (auto i = a; i < b; ++i)
#define nfo(a, b) for (auto i = a; i >= b; --i)
#define jfo(a, b) for (auto j = a; j < b; ++j)
#define njfo(a, b) for (auto j = a; j >= b; --j)
class solution
{
public:
void solve()
{
int n, k, mx = 0, cmx = 0;
cin >> n >> k;
unordered_map<int, int> mp;
vector<int> arr(n);
set<int> s;
fo(0, n)
{
cin >> arr[i];
s.insert(arr[i]);
mp[arr[i]] += 1;
if (mp[arr[i]] > mx)
{
mx = mp[arr[i]];
cmx = arr[i];
}
}
int ans = INT_MAX;
for (auto it : s)
{
int ans_temp = 0;
fo(0, n)
{
if (arr[i] != it)
{
ans_temp += 1;
i += k - 1;
}
}
ans = min(ans, ans_temp);
}
cout << ans << endl;
}
};
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t{1}, x{1};
cin >> t;
while (t--)
{
x++;
solution a;
a.solve();
};
}
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |
Divisibility | A. Movement |
Numbers in a matrix | Sequences |
Split houses | Divisible |